64.1.1 Deduced “grab” Dependencies
64.1.1 推断"grab"依赖
标准的Groovy包含一个@Grab注解,它允许你声明对第三方库的依赖。这项有用的技术允许Groovy以和Maven或Gradle相同的方式下载jars,但不需要使用构建工具。
Spring Boot进一步延伸了该技术,它会基于你的代码尝试推导你"grab"哪个库。例如,由于WebApplication代码上使用了@RestController注解。Spring Boot会获取"Tomcat"和"Spring MVC"。
下列条目被用作"grab提示":
| 条目 | Grabs | 
|---|---|
| JdbcTemplate,NamedParameterJdbcTemplate,DataSource | JDBC应用 | 
| @EnableJms | JMS应用 | 
| @EnableCaching | 缓存抽象 | 
| @Test | JUnit | 
| @EnableRabbit | RabbitMQ | 
| @EnableReactor | 项目重构 | 
| extends Specification | Spock测试 | 
| @EnableBatchProcessing | Spring Batch | 
| @MessageEndpoint,@EnableIntegration | Spring集成 | 
| @Controller,@RestController,@EnableWebMvc | Spring MVC + 内嵌Tomcat | 
| @EnableWebSecurity | Spring Security | 
| @EnableTransactionManagement | Spring事务管理 | 
注 想要理解自定义是如何生效的,可以查看Spring Boot CLI源码中的CompilerAutoConfiguration子类。